<?xml version="1.0" encoding="utf-8"?><!-- DWXMLSource="http://localhost/myfav/?type=addfavui" --><!DOCTYPE xsl:stylesheet  [
	<!ENTITY nbsp   "&#160;">
	<!ENTITY copy   "&#169;">
	<!ENTITY reg    "&#174;">
	<!ENTITY trade  "&#8482;">
	<!ENTITY mdash  "&#8212;">
	<!ENTITY ldquo  "&#8220;">
	<!ENTITY rdquo  "&#8221;"> 
	<!ENTITY pound  "&#163;">
	<!ENTITY yen    "&#165;">
	<!ENTITY euro   "&#8364;">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="/">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>添加收藏</title>
<base target="_self" />
<link href="css/main.css" rel="stylesheet" type="text/css" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<style type="text/css">
html,body { overflow:hidden;}
</style>
<script type="text/javascript">
<xsl:comment>
document.onkeydown = function(){
	if(event.keyCode==27){
		window.close();
	}
}
function check(f){
	if(f.title.value==""){
		alert("标题不能为空！");
		f.title.focus();
		return false;
	}
	if(f.url.value==""){
		alert("链接不能为空！");
		f.url.focus();
		return false;
	}
	return true;
}
function initPara(){
	var para = location.search.substring(1).split("&amp;");
	var obj = {};
	for(var i=0,j; j=para[i]; i++){
		var t = j.split("=");
		obj[t[0].toLowerCase()] = t[1];
	}
	var f = document.forms["form1"];
	f.title.value = decodeURIComponent(obj['title']);
	f.url.value = decodeURIComponent(obj['url']);
}
</xsl:comment>
</script>
</head>
<body onload="initPara()">
<div class="add">
<h1>添加收藏</h1>
<form id="form1" name="form1" method="post" action="?type=addfav" onsubmit="return check(this)">
  <table border="0" cellpadding="6" cellspacing="0">
    <tr>
      <td>标题：</td>
      <td><input type="text" name="title" id="title" class="txt" onfocus="this.select()" value="{/root/addform/title}" /></td>
    </tr>
    <tr>
      <td>链接：</td>
      <td><input type="text" name="url" id="url" class="txt" onfocus="this.select()" value="{/root/addform/url}" /></td>
    </tr>
    <tr>
      <td>分类：</td>
      <td>
      	<select name="category">       
        <xsl:element name="option">
        	<xsl:attribute name="value">0</xsl:attribute>
            <xsl:if test="not(/root/category/cat[@default=1]) and not(/root/addform/cat)">
            	<xsl:attribute name="selected" />
            </xsl:if>
            <xsl:text>├未分类</xsl:text>
        </xsl:element>
      	<xsl:call-template name="getOptions">
        <xsl:with-param name="pid" select="0" />
        <xsl:with-param name="str" select="string('┝')" />
        </xsl:call-template>
        </select>
      </td>
    </tr>
    <tr>
    	<td colspan="2" align="right"><span class="err"><xsl:value-of select="/root/error" disable-output-escaping="yes" /></span><button type="submit">添加</button></td>
    </tr>
  </table>
</form>
<span class="user">当前用户：<xsl:value-of select="/root/username" /></span>
</div>
</body>
</html>

</xsl:template>

<xsl:template name="getOptions">
<xsl:param name="pid" />
<xsl:param name="str" />
<xsl:for-each select="/root/category/cat[@pid=$pid]">
<xsl:variable name="cid" select="@id" />
<xsl:element name="option">
	<xsl:attribute name="value"><xsl:value-of select="@id" /></xsl:attribute>
    <xsl:attribute name="title"><xsl:value-of select="." /></xsl:attribute>
    <xsl:if test="(@default=1 and not(/root/addform/cat)) or /root/addform/cat=@id">
    <xsl:attribute name="selected" />    
    </xsl:if>
    <xsl:value-of select="$str" /> <xsl:value-of select="." />
</xsl:element>

<xsl:if test="/root/category/cat[@pid=$cid]">
	<xsl:call-template name="getOptions">
    <xsl:with-param name="pid" select="$cid" />
    <xsl:with-param name="str" select="concat('　',$str)" />
    </xsl:call-template>
</xsl:if>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>